$ = function(el){
return document.getElementById(el);
}
delay = 1500;
canvasWidth = document.body.clientHeight;
canvasHeight = document.body.clientHeight;
Polaroid = function(location, title, w, h, service){
	return {
		init: function(){
			var self = this;
			title = title ? title : '';
			this.image = document.createElement('div');
			var i = this.image;
			var j = document.createElement('div');
			fakeImg = document.createElement('img');
			fakeImg.style.display = 'hidden'; 
			fakeImg.onload = function(){
				self.onLoad(self);
				$('loadingbay').removeChild(this);
			}
			fakeImg.src = location;
			$('loadingbay').appendChild(fakeImg);
			
			i.className = 'holder';
			i.style.background = 'url('+location+')';
			if(w > h){
				j.className = 'image w';
			} else {
				j.className = 'image h';
			}
			i.appendChild(j);
			var b = document.createElement('div');
			b.innerHTML = title;
			b.className = 'title';
			i.appendChild(b);
			document.body.appendChild(i);
		},
		location: location,
		service: service,
		image: null,
		onLoad: function(img){
			PolyQueue.push(img);
		},
		move: function(){
			var i= this.image;
			i.style.webkitTransform = 'opacity 1s ease-in-out';
			i.className = 'holder new';
			$('moby').className = '';
			$('hyves').className = '';
			$('twitter').className = '';
			$(this.service).className = 'highlight';
		}
	}
}

randomLocation = function(){
	var x = canvasWidth + Math.floor(Math.random()*500)+500;
	var y = canvasHeight + Math.floor(Math.random()*500)+500;
	return new Array(x, y);
}

PolyQueue = new Array();
PolyRemoveQueue = new Array();
loader = true;

processQueue = function(){
	if(PolyQueue.length){
		var p = PolyQueue.shift();
		p.move();
		PolyRemoveQueue.push(p);
	}
	window.setTimeout('processQueue()', (5000+Math.random()*delay));
	r = window.setTimeout('processRemoveQueue()', (Math.random()*delay));
}
processRemoveQueue = function(){
	if(PolyRemoveQueue.length > 1){
		var p = PolyRemoveQueue.shift();
		document.body.removeChild(p.image);
		delete(p);
	}
}
getFont = function(){
	var Fonts = new Array('assign','grunge','aescrawl','carbon','zimmerman','girls','buttons','appetite','dad','abscissa');
	var r = Math.random()*(Fonts.length);
	return Fonts[Math.floor(r)];
}
t = window.setTimeout('processQueue()', (Math.random()*delay));
